import http from './request';

// 登陆
const adminLogin = (params: ILoginParams): PRES<ILoginModel> => http.post('admin/login', params);

// 获取当前用户的信息
const adminInfo = (): PRES<IAdminInfoModel> => http.get('admin/info');

// 获取 一级菜单 权限  下面的  用户列表的数据
const adminList = (params: IAdminListParams): PRES<IAdminListModel> => http.get('admin/list', { params });

// 修改 账号状态(是否启用)
const updateStatus = (id: number, status: number): PRES<number> => http.post(`admin/updateStatus/${id}?status=${status}`);

// 注册 新增 用户
const adminRegister = (params: IUserModel): PRES<IUserModel> => http.post('admin/register', params);

// 根据 用户id 获取指定用户信息 admin/{id}
const getAdminInfoById = (id: number): PRES<IUserModel> => http.get(`admin/${id}`);

// 编辑/修改 指定id用户的信息  admin/update/{id}  修改指定用户信息
const updateAdminInfoById = (params: IUserModel): PRES<IUserModel> => http.post(`admin/update/${params.id}`, params);

// 根据id 获取指定用户的角色   // admin/role/{adminId}
const getAdminRoleById = (adminId: number): PRES<IRoleModel[]> => http.get(`admin/role/${adminId}`);

// admin/role/update
// 根据id 给指定用户 分配(更新)角色
const updateAdminRoleById = (params: { adminId: number, roleIds: number[] }): PRES<number> => http.post(`admin/role/update?adminId=${params.adminId}&roleIds=${params.roleIds}`);

export {
  adminLogin,
  adminInfo,
  adminList,
  updateStatus,
  adminRegister,
  getAdminInfoById,
  updateAdminInfoById,
  getAdminRoleById,
  updateAdminRoleById,
}